package main.Q701_800;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Q781_790 {
    public static void main(String[] args) {
        System.out.println("Question781：森林中的兔子");
        System.out.println("Question782：");
        System.out.println("Question783：");
        System.out.println("Question784：字母大小写全排列");
        System.out.println("Question785：");
        System.out.println("Question786：");
        System.out.println("Question787：");
        System.out.println("Question788：");
        System.out.println("Question789：逃脱阻碍者");
        int[][] ghosts = new int[][]{{1, 0}, {0, 3}};
        System.out.println(new Question789().escapeGhosts(ghosts, new int[]{0, 1}));
        System.out.println("Question790：");
    }
}

class Question781 {
    public int numRabbits(int[] answers) {
        int count = 0, length = answers.length;
        Map<Integer, Integer> map = new HashMap<>();
        for (int num : answers) map.put(num, map.getOrDefault(num, 0) + 1);
        for (Integer key : map.keySet()) {
        }
        return count;
    }
}

class Question784 {
    List<String> list = new ArrayList<>();

    public void process(String s, int index, StringBuffer str) {
        if (index >= s.length()) {
            list.add(str.toString());
            return;
        }
        char c = s.charAt(index);
        StringBuffer curStr = new StringBuffer(str);
        if (c >= '0' && c <= '9') {
            curStr.append(c);
            process(s, index + 1, curStr);
        } else {
            curStr.append(c);
            process(s, index + 1, curStr);
            if (c <= 'z' && c >= 'a') {//转大写
                curStr.deleteCharAt(curStr.length() - 1);
                curStr.append(Character.toUpperCase(c));
                process(s, index + 1, curStr);
            } else {
                curStr.deleteCharAt(curStr.length() - 1);
                curStr.append(Character.toLowerCase(c));
                process(s, index + 1, curStr);
            }
        }
    }

    public List<String> letterCasePermutation(String s) {
        StringBuffer stringBuffer = new StringBuffer();
        process(s, 0, stringBuffer);
        return list;
    }
}

class Question789 {
    public int process(int[] ghost, int[] target) {
        int distance = Math.abs(ghost[0] - target[0]) + Math.abs(ghost[1] - target[1]);
        return distance;
    }

    public boolean escapeGhosts(int[][] ghosts, int[] target) {
        int originDis = process(new int[]{0, 0}, target);
        for (int[] ghost : ghosts) {
            int curDis = process(ghost, target);
            if (curDis <= originDis) {
                return false;
            }
        }
        return true;
    }
}